package w3

class S {
  private var _age: Int = 0
  private var _name: String = ""

  def value = _name

  def value_(n: String): Unit = {
    _name = n
  }

  def age = _age

  def age_=(newAge: Int): Unit = {
    if (newAge > 60 || newAge < 10)
      _age = 22
    else
      _age = newAge
  }

  override def toString = _name + "," + _age.toString
}

object TEstCounter {
  def main(args: Array[String]): Unit = {
    var s = new S()
    s.age = 112
    //s.value = "老吴"
    println(s.age)
    println(s)

  }
}
